package models

// LianBankCode 联动联行号
type LianBankCode struct {
	ID           uint   `json:"id" form:"id" gorm:"primary_key;AUTO_INCREMENT;comment:'id'"`
	BankCode     string `json:"bank_code" gorm:"comment:'支行号'"`
	Name         string `json:"name" gorm:"comment:'支行名称'"`
	BaseName     string `json:"base_name" gorm:"comment:'总行名称'"`
	ProvinceName string `json:"province_name" gorm:"comment:'省名称'"`
	CityName     string `json:"city_name" gorm:"comment:'市名称'"`
}

func LianBankCodeListByBaseName(baseName, city string) []*LianBankCode {
	var result = make([]*LianBankCode, 0)
	db.Model(&LianBankCode{}).Where("base_name LIKE ? AND city = ?", "%"+baseName+"%", city).Scan(&result)
	return result
}

func GetBankCodeById(id interface{}) *LianBankCode {
	var code *LianBankCode
	db.Model(&LianBankCode{}).Where("id = ?", id).First(&code)
	return code
}
